<?php

namespace app\common\model;

/**
 * [ActsOrder  寺院项目订单表]
 * @author [C。]
 * @return html
 */
class ActsOrder extends Base
{
    protected $name = 'acts_order';
    /**
     * 获取充值列表总数
     * @param array $param
     */
    public function getRechargeCount($map) {
        return $this->where($map)->count();
    }
    /**
     * 获取已经募捐金额
     * @param array $param
     */
    public function getAlreadyRaising($aid) {
        return $this->where(['aid'=>$aid])->sum('money');
    }
    /**
     * [getlist  获取分页列表]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getlist($map, $from = 0, $size = 5,$field='*')
    {
        $order = ['id' => 'desc'];
        return  $this->field($field)->where($map)->limit($from, $size)->order($order)->select();
    }
    /**
     * [getCount  获取总数]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getCount($map)
    {
        return  $this->where($map)->count();
    }
    /**
     * [getlist  获取分页列表]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getlists($map, $from = 0, $size = 5,$field='*')
    {
        $order = ['o.id' => 'desc'];
        $join1 = [
            ['app_company c','c.id = o.comid'],
        ];
        $join2 = [
            ['app_acts a','a.id = o.aid'],
        ];
        return  $this->field($field)
            ->alias('o')
            ->join($join1)
            ->join($join2)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();
    }
    /**
     * [getCount  获取总数]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function getCounts($map)
    {
        $join1 = [
            ['app_company c','c.id = o.comid'],
        ];
        $join2 = [
            ['app_acts a','a.id = o.aid'],
        ];
        return  $this->alias('o')
            ->join($join1)
            ->join($join2)
            ->where($map)
            ->count();
    }
}